LED0 EQU 0x422101a0 
RCC_APB2ENR EQU 0x40021018
GPIOA_CRH EQU 0x40010804
GPIOA_ODR EQU 0x4001080C

Stack_Size      EQU     0x00000400

                AREA    STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem       SPACE   Stack_Size
__initial_sp

                AREA    RESET, DATA, READONLY
					
__Vectors       DCD     __initial_sp               ; Top of Stack
                DCD     Reset_Handler              ; Reset Handler    
                    
                AREA    |.text|, CODE, READONLY
                    
                THUMB
                REQUIRE8
                PRESERVE8          
					
					
                ENTRY
Reset_Handler 
                BL LED_Init
				
MainLoop        BL LED_ON
                BL Delay
                BL LED_OFF
                BL Delay
                
                B MainLoop
             
			 
LED_Init
                ;PUSH {R0,R1,LR}
                
                LDR R0,=RCC_APB2ENR
				LDR R1,[R0] 
                ORR R1,R1,#0x04
                STR R1,[R0]
                
                LDR R0,=GPIOA_CRH
				LDR R1,[R0] 
                BIC R1,R1,#0x0F
                STR R1,[R0]
                
                LDR R0,=GPIOA_CRH
				LDR R1,[R0] 
                ORR R1,R1,#0x03
                STR R1,[R0]
                
                MOV R1,#1 
                LDR R0,=LED0
                STR R1,[R0]
             
				BX LR
                ;POP {R0,R1,PC}

             
LED_ON
                ;PUSH {R0,R1, LR}    
                
                MOV R1,#0 
                LDR R0,=LED0
                STR R1,[R0]
					
				BX LR
                ;POP {R0,R1,PC}
             
LED_OFF
                ;PUSH {R0,R1,LR}    
                
                MOV R1,#1 
                LDR R0,=LED0
                STR R1,[R0]
             
				BX LR
                ;POP {R0,R1,PC}  

LED_TOGGLE
				;PUSH {R0,R1,LR} 
				
				LDR R0,=GPIOA_ODR
				LDR R1,[R0]  ;R1 = *R0
				EOR R1,#0x0100 ;r1 = r1^0x0100
				STR R1,[R0] ;*R0 = R1 
				
				BX LR
				;POP {R0,R1,PC} 
							
Delay
                ;PUSH {R0,R1,LR}
                
                MOVS R0,#0
                MOVS R1,#0             
DLoop0        
                ADDS R0,R0,#1

                CMP R0,#500
                BCC DLoop0
                
                MOVS R0,#0
                ADDS R1,R1,#1
                CMP R1,#500
                BCC DLoop0

				BX LR
               ;POP {R0,R1,PC}    
             
             END